package design.simdi.code.final_paper.site.panels;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;

/**
 * 
 * @author Marius Dumitriu - (Jun 26, 2010 - 6:11:31 PM)
 * 
 */
public abstract class YesNoPanel extends OneButtonPanel {

	private static final long serialVersionUID = 1L;
	private AjaxFallbackButton ok;

	public YesNoPanel(String id) {
		super(id);
	}

	public YesNoPanel(String id, IModel<?> model) {
		super(id, model);
	}

	@Override
	public void panelInit() {
		setOutputMarkupId(true);
		super.panelInit();

		setOk(new AjaxFallbackButton("ok", getForm()) {

			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

				onYESButtonSubmit(target);

			}
		});
		getForm().add(getOk());
	}

	public void setOk(AjaxFallbackButton ok) {
		this.ok = ok;
	}

	public AjaxFallbackButton getOk() {
		return ok;
	}

	public abstract void onYESButtonSubmit(AjaxRequestTarget target);
}
